//
//  Test43.cpp
//  CPPTest
//
//  Created by you5 Yi on 2021/9/29.
//

#include "Test43.hpp"
#include <iostream>
#include <string>
using namespace std;
class str4
{
private:
    char *st;
public:
    str4(char *a)
    {
        set(a);
    }
    str4 &operator=(str4 &a) {
        delete st;
        set(a.st);
        return *this;
    }
    void show()
    {
        cout<<st<<endl;
    }
    ~str4() {
        delete st;
    }
    void set(char *s)
    {
        st = new char[strlen(s)+1];
        strcpy(st, s);
    }
};

void test43() {
    str4 s1("hello"),s2("world");
    s1.show(),s2.show();
    s2=s1;
    s1.show(),s2.show();
}
